<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>MYSHOP 管理中心 - 添加属性 </title>
<meta name="robots" content="noindex, nofollow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <css file="__PUBLIC__/Admin/css/general.css" />
  <css file="__PUBLIC__/Admin/css/main.css" />
  <script type="text/javascript" src="__PUBLIC__/Admin/js/transport.js"></script>  
  <script type="text/javascript" src="__PUBLIC__/Admin/js/common.js"></script>

</head>
<body>

<h1>
  <span class="action-span"><a href="{:U('attrList', array('id' => $_GET['tid']))}">商品属性</a></span>
  <span class="action-span1"><a href="">MYSHOP 管理中心</a> </span><span id="search_id" class="action-span1"> - 添加属性 </span>
  <div style="clear:both"></div>
</h1>
<div class="main-div">
  <form action="{:U('runAddAttr')}"  method="post" name="theForm" onsubmit="return validate();">
  <table width="100%" id="general-table">
      <tr>
        <td class="label">属性名称：</td>
        <td>
          <input type='text' name='name' value="" size='30' />
          <span class="require-field">*</span>        </td>
      </tr>
            
      <tr>
        <td class="label">属性类型：</td>
        <td>
          <input type="radio" name="type" value="0"  checked="true"  /> 属性          <input type="radio" name="type" value="1"  /> 规格        </td>
      </tr>
      
      
      <tr>
        <td class="label">属性值：</td>
        <td>
          <textarea name="value" cols="30" rows="5"></textarea>
        </td>
      </tr>
      <tr>
        <td colspan="2">
        <div class="button-div">
          <input type="submit" value=" 确定 " class="button"/>
          <input type="reset" value=" 重置 " class="button" />
        </div>
        </td>
      </tr>
      </table>
    <input type="hidden" name='tid' value='{$Think.get.tid}'>
  </form>
</div>
<script type="text/javascript" src="__PUBLIC__/Admin/js/utils.js"></script>
<script type="text/javascript" src="__PUBLIC__/Admin/js/validator.js"></script>
<script language="JavaScript">
<!--
onload = function()
{

  radioClicked(0);
  onChangeGoodsType(1);
  // 开始检查订单
  startCheckOrder();

}

/**
 * 检查表单输入的数据
 */
function validate()
{
  var ele = document.forms['theForm'].elements;
  var msg = '';

  if (Utils.trim(ele['attr_name'].value) == '')
  {
    msg += name_not_null + '\n';
  }

  if (ele['cat_id'].value == 0)
  {
    msg += cat_id_not_null + '\n';
  }

  if (ele['attr_input_type'][1].checked && Utils.trim(ele['attr_values'].value) == '')
  {
    msg += values_not_null + '\n';
  }

  if (msg.length > 0)
  {
    alert(msg);
    return false;
  }
  else
  {
    return true;
  }
}

/**
 * 点击类型按钮时切换选项的禁用状态
 */
function radioClicked(n)
{
  document.forms['theForm'].elements["attr_values"].disabled = n > 0 ? false : true;
}

/**
 * 改变商品类型的处理函数
 */
function onChangeGoodsType(catId)
{
  Ajax.call('attribute.php?act=get_attr_groups&cat_id=' + catId, '', changeGoodsTypeResponse, 'GET', 'JSON');
}

function changeGoodsTypeResponse(res)
{
  if (res.error == 0)
  {
    var row = document.getElementById('attrGroups');
    if (res.content.length == 0) {
      row.style.display = 'none';
    } else {
      row.style.display = document.all ? 'block' : 'table-row';

      var sel = document.forms['theForm'].elements['attr_group'];

      sel.length = 0;

      for (var i = 0; i < res.content.length; i++)
      {
        var opt = document.createElement('OPTION');
        opt.value = i;
        opt.text = res.content[i];
        sel.options.add(opt);
        if (i == '')
        {
          opt.selected=true;
        }
      }
    }
  }

  if (res.message)
  {
    alert(res.message);
  }
}

//-->
</script>

<div id="footer">
共执行 3 个查询，用时 0.021679 秒，Gzip 已禁用，内存占用 3.631 MB<br />
版权所有 &copy; 2005-2012 上海商派网络科技有限公司，并保留所有权利。</div>

</body>
</html>